﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Chapter04
{
    public partial class Example109 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["key"]))
            {
                var data = new List<string> { "奋斗", "前途", "无奈", "生活", "穷困", "潦倒" };
                var result = data.Find((item) => item == Request.QueryString["key"]);
                resultLabel.Text = string.IsNullOrEmpty(result) ? "空" : result;

            }
        }

        protected void searchButton_Click(object sender, EventArgs e)
        {
            if (searchTextBox.Text.Length > 0)
            {
                Response.Redirect("Example109.aspx?key=" + searchTextBox.Text.Trim());
            }
        }
    }
}